<?php
	//Xay dung tim kiem
	$ssFilter 		= $this->arrParam['ssFilter'];
	$page = '';
	if(isset($this->arrParam['page'])){
		$page = '/page/' . $this->arrParam['page'];
	}
	$action_link 	= $this->baseUrl($this->currentController . '/filter/type/order');
	$lblName 		= $this->cmsLinkSort('Tiêu đề','p.name',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblID 			= $this->cmsLinkSort('ID','p.id',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblModule 		= $this->cmsLinkSort('Module','p.module',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblController	= $this->cmsLinkSort('Controller','p.controller',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblAction		= $this->cmsLinkSort('Action','p.action',$ssFilter,$this->imgUrl . '/admin',$action_link);
	
	//--------------------- SEARCH --------------------//
	$keywords 		= $this->formText('keywords',$ssFilter['keywords'],array('class'=>'txtshort txtsearch'));
	$linkSearch 	= $this->baseUrl($this->currentController . '/filter/type/search/key/1');
	$btnSearch 		= $this->formButton('search-now','Tìm',array('class' => 'btnsearch', 'onclick'=>"OnSubmitForm('" .$linkSearch . "')"));
	$linkResetSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/0');
	$btnResetSearch = $this->formButton('clear-keywords','Xóa',array('class' => 'btnsearch', 'onclick'=>"OnSubmitForm('" .$linkResetSearch ."')"));
	
	$strSearch = $keywords . ' ' . $btnSearch . ' ' . $btnResetSearch;
	
	$filter = new Zendvn_GetSystem();
	$module = $filter->getAll();
	$slbModule[0] = 'Tất cả các module';
	foreach ($module AS $key => $val){
		$slbModule[$key] = $key;
	}
	$linkSlbModule = $this->baseUrl($this->currentController . '/filter/type/p_module');
	$selectModule = $this->formSelect('p_module',$ssFilter['p_module'],array('onchange'=>"OnSubmitForm('" .$linkSlbModule ."')"),$slbModule);
	
	$strSearchRight = $selectModule;
?>

<div class="left_content">
	<?php echo $this->render($this->arrParam['controller'] . '/toolbar/left.php');?>
</div>

<div class="right_content">
	<div class="appContent">
		<form action="" method="post" name="appForm">
			<?php echo $this->render($this->arrParam['controller'] . '/toolbar/index.php');?>
			<?php
			if($this->arrParam['save'] == 'ok'){
				echo '<div class="thongbaoThanhCong goc5">Xử lý dữ liệu thành công</div>';
			} 
			?>
			<div class="formList goc5">
				<div class="appTop goct5">
					<div class="block_filter">
						<div class="fl">
							<div class="listSearch">
								<?php echo $strSearch; ?>
								<div class="clr"></div>			
							</div>
						</div>
						<div class="fr">
							<div class="listSelect">
								<?php echo $strSearchRight;?>
								<div class="clr"></div>
							</div>
						</div>
						<div class="clr"></div>
					</div>
				</div>
				<div class="appBody">
					<table class="tblList">
						<tr>
							<th width="20">#</th>
							<th width="20"><input type="checkbox" name="checkbox" id="checkbox" onclick="checkedAll()"></th>
							<th><?php echo $lblName;?></th>
							<th><?php echo $lblModule;?></th>
							<th><?php echo $lblController;?></th>
							<th><?php echo $lblAction;?></th>
							<th width="70">Control</th>
							<th width="50"><?php echo $lblID;?></th>
						</tr>
						<?php
						foreach ($this->Items as $key => $val){
							$id 			= $val['id'];
							$name 			= $val['name'];
							$module			= $val['module'];
							$controller		= $val['controller'];
							$action			= $val['action'];
								
							$linkEdit		= $this->baseUrl($this->currentController . '/edit/id/' . $id . $page);
							$btnEdit		= $this->cmsIconButton('Sửa', $this->imgUrl . '/admin/icon_edit.png', $linkEdit);
								
							$linkDelete		= $this->baseUrl($this->currentController . '/delete/id/' . $id . $page);
							$btnDelete		= $this->cmsIconButton('Xóa', $this->imgUrl . '/admin/publish_r.png', $linkDelete);
								
							$strIconButton 	= $btnEdit . $btnDelete;
								
							$name 	= '<a href="' . $linkEdit . '">' . $name . '</a>';

							$cid 			= $this->formCheckbox('cid[]',$val['id']);
							$classRow = 'row1';
							if($key % 2 == 0)
								$classRow = '';
						?>
						<tr class="<?php echo $classRow;?>">
							<td align="center"><?php echo $key + 1;?></td>
							<td align="center"><?php echo $cid;?></td>
							<td align="left"><?php echo $name;?></td>
							<td align="left"><?php echo $module;?></td>
							<td align="left"><?php echo $controller;?></td>
							<td align="left"><?php echo $action;?></td>
							<td align="center"><?php echo $strIconButton;?></td>
							<td align="center"><?php echo $id;?></td>
						</tr>
						<?php
						} 
						?>
					</table>
				</div>
				<div class="appBottom">
					<?php
						$currentUrl = $this->baseUrl($this->currentController . '/index');
						echo $this->paginationControl($this->paginator,'Sliding','pagination.phtml',array('currentUrl'=>$currentUrl)); 
					?>
				</div>
			</div>
		</form>
	</div>
</div>
<div class="clr"></div>
